<template>
	<view  style="padding: 40rpx;">
			
		<u--form :model="form" ref="form" style="padding: 20px;">
			<u-form-item label="客户名称" prop="name">

				<input class="input" v-model="form.name" />
			</u-form-item>

			<u-form-item label="联系人" prop="address">
				<input class="input" v-model="form.linkman" />
			</u-form-item>

			<u-form-item label="联系电话" prop="address">
					<input class="input" v-model="form.phone" />
			
			</u-form-item>


			<u-form-item label="联系地址" prop="address">
				<input class="input" v-model="form.address" />
			</u-form-item>
		</u--form>
		<u-button type="primary" @click="submit">保存</u-button>
		<u-toast ref="uToast"></u-toast>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				form: {
					companyId:"",
					id: "",
					name: "",
					linkman: "",
					phone: "",
				}
			}
		},
		methods: {
			submit() {
				var that=this
				this.api.post("/customer", this.form).then(res => {
					that.$refs.uToast.show({
						type: 'default',
						title: '提示',
						message: res.mes,
						iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/default.png'
					})
					uni.navigateBack();
					console.log(res)
				})
			}
		},
		onLoad(options) {
			this.form.companyId=this.$store.state.myCompanyId
			var that =this
			if(Object.keys(options).length!=0){
				this.form.id=options.id
				this.api.get("/customer/myCustomerInfo/"+this.form.id,{}).then(res => {
					console.log(res)
					that.form=res.data
					
				})
			}
			
		}
	}
</script>

<style>
	.input {
		border-bottom: 1rpx #BBBCC6 solid;
	}
</style>
